/**
 * 日志监控JS-loggerInfo.jsp
 */
var strPath = window.document.location.pathname;
//var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
var postPath = "/gdp";
var interval = setInterval("getrealTimeLoginfo()",5000);
//查询实时日志消息
function getrealTimeLoginfo(){
	$.ajax({
		type : 'POST',
        url : postPath + '/system/monitor/showInformation',
		success: function(data){
			$("#logcontent").prepend(data);
		}
	});
}
$(function(){
	//性能监控最低阀值获取
	$.ajax({
		url : postPath + '/system/monitor/querytimeInterval',
		type : "POST",
		data : "",
		async : true,
		dataType : "JSON",
		success : function(result) {
			$("#seachTxt").val(result)
		}, 
		error : function(error) {
		}
	});
	
	//实时监控
	$('#pulsate-regular').pulsate({
        color: "#F3565D"
    });
	
	$('#mySwitch').bootstrapSwitch({
		onText:'开启',  
        offText:'关闭' 
	});
	
	$("#btn_Setting").click(function(){
		$.ajax({
			url : postPath + '/system/monitor/settimeInterval',
			type : "POST",
			data : {'timeid':$("#seachTxt").val()},
			async : true,
			dataType : "JSON",
			success : function(result) {
		
			}, 
			error : function(error) {
			}
		});
	});
	$("#mySwitch").on('switchChange.bootstrapSwitch', function (e, state) {
        if(state){//状态为开启
        	$('#pulsate-regular').pulsate({
                color: "#F3565D"
            });
        	interval = setInterval("getrealTimeLoginfo()",5000);
        	$.ajax({
    			url : postPath + '/system/monitor/setActiveMqPush',
    			type : "POST",
    			data : {'id':'0'},
    			async : true,
    			dataType : "JSON",
    			success : function(result) {
    		
    			}, 
    			error : function(error) {
    			}
    		});
		 }
		 else{//状态为0FF
			 $("#pulsate-regular").pulsate("destroy");
			 clearInterval(interval);
			 $.ajax({
					url : postPath + '/system/monitor/setActiveMqPush',
					type : "POST",
					data : {'id':'1'},
					async : true,
					dataType : "JSON",
					success : function(result) {
				
					}, 
					error : function(error) {
					}
				});
		 }
});
})
